package com.cropdoctor.model.doc;

import com.cropdoctor.model.po.PostPo;
import com.cropdoctor.model.po.PublishCoursePo;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.time.LocalDateTime;

@Data
@NoArgsConstructor
public class PostDoc {
    private String title;

    String url;
    private String create_date_time;
    private long id;

    public PostDoc(PostPo postPo) {
        BeanUtils.copyProperties(postPo,this);
        int index = postPo.getCreateDateTime().toString().lastIndexOf('.');
        if(index != -1){
            create_date_time = postPo.getCreateDateTime().toString().substring(0,index);
        }else{
            create_date_time = postPo.getCreateDateTime().toString();
        }
    }
}
